[1] 11 22 33
[,1] [,2] [,3]
[1,] 11 22 33
my experience with rBAPS
Oslo Centre for Biostatistics and Epidemiology, UiO
2024-05-30
Translate core functionality of BAPS from MATLAB to R
(buckle up, kiddos)
Go from top-level functions down the rabbit hole or the other way around?
| Aspect | ⬇ Top-down | ⬆ Bottom-up |
|---|---|---|
| Chance for errors | Higher | Lower |
| Chance to waste coding | Lower | Higher |
| Initial speed | Fast | Slow |
Result: 4 years of “one step forward, one step back”
<rant><matlab>
“WTF are these shortcuts? Alt+WAlt+W to copy? Ctrl+YCtrl+Y pastes?”
(FWIW this is all fixed in MATLAB Online)
nargin()?”if testaaPop(line3)==1
%2 rivi tällöin lokusrivi
nloci = rivinSisaltamienMjonojenLkm(line2);
line4 = fgetl(fid);
if isequal(line4,-1)
disp('Incorrect file format'); fclose(fid);
return
end
if ~any(line4==',')
% Rivin nelj?täytyy sisältää pilkku.
disp('Incorrect file format'); fclose(fid);
return
end
pointer = 1;
while ~isequal(line4(pointer),',') %Tiedetään, ett?pysähtyy
pointer = pointer+1;
end
line4 = line4(pointer+1:end); %pilkun jälkeinen osa
nloci2 = rivinSisaltamienMjonojenLkm(line4);
if (nloci2~=nloci)
disp('Incorrect file format'); fclose(fid);
return
end
endAre those subsets or function calls?
>> 10:-1:1
ans =
10 9 8 7 6 5 4 3 2 1
>> a = max(10:-1:1)
a =
10
>> [a, b] = max(10:-1:1)
a =
10
b =
1</matlab><r>
“So x is not even a row vector?”
[1] 11 22 33
[,1] [,2] [,3]
[1,] 11 22 33
NULL
[1] 1 3
[1] "numeric"
[1] "matrix" "array"
Or maybe it’s just the way we rely on c() instead of matrix() for creating vectors?
Nope. “Core R” does it too:
[,1] [,2] [,3]
[1,] 11 14 17
[2,] 12 15 18
[3,] 13 16 19
[1] "integer"
No, not "double" as before. Don’t get me started on R’s dynamic typing shenanigans.
Nope. “Core R” does it too:
[,1] [,2] [,3]
[1,] 11 14 17
[2,] 12 15 18
[3,] 13 16 19
[1] "integer"
[1] "matrix" "array"
</r></rant>
After 450 hours of work:
i.e., back to basics, taking it slow (which finally seems to be working)
After 4 years working as an RSE
Understand and disseminate the differences.
| Product | Chances to publish | Patches |
|---|---|---|
| Research paper | “one” | “embarrassing” |
| Research software | “infinite” | good |
Publishing your code actually protects it!
Commit and push timestamps your work
Thank you for your attention!
Thank you for hosting us! ❤️ 🇫🇮